Eyeshot 11 Documentation
WinForms Control / Tutorials / Vector printing with custom scaling
In This Topic
    Vector printing with custom scaling
    In This Topic

    If you want to print on paper the view displayed in ViewportLayout control, you can follow the approach reported in this article.

    Suppose that your viewport looks like this:

    Capture1.PNG

    and you want to print it on paper in hidden line mode.

    Your printButton handler should contain the following code lines:

    private void printButton_Click(object sender, EventArgs e)
    {
       //Save current view Camera
       cameraSaved = (Camera)viewportLayout1.Camera.Clone();
    
       viewportLayout1.Camera.ProjectionMode = projectionType.Orthographic;
    
       //Creates printing setting object and customize it
       HiddenLinesViewSettings hdlS = new HiddenLinesViewSettings(viewportLayout1);
       hdlS.PenEdge.Color = Color.Blue;
       hdlS.PenSilhouette.Color = Color.Blue;
       hdlS.PenEdge.Width = 1f;
       hdlS.PenSilhouette.Width = 1f;
    
       //Creates paper preview
       HiddenLinesViewOnPaperPreview hdl = new HiddenLinesViewOnPaperPreview(hdlS, new Size(800, 600), 0.25);
       viewportLayout1.StartWork(hdl);
    
       //Restore saved view
       viewportLayout1.RestoreView(cameraSaved);
    } 
    Private Sub printButton_Click(sender As Object, e As EventArgs)
        'Save current view
        Dim cameraSaved As Camera = DirectCast(ViewportLayout1.Camera.Clone(), Camera)
    
        ViewportLayout1.Camera.ProjectionMode = projectionType.Orthographic
    
        'Creates printing setting object and customize it
        Dim hdlS As New HiddenLinesViewSettings(viewportLayout1)
        hdlS.PenEdge.Color = Color.Blue
        hdlS.PenSilhouette.Color = Color.Blue
        hdlS.PenEdge.Width = 1F
        hdlS.PenSilhouette.Width = 1F
    
        'Creates paper preview
        Dim hdl As New HiddenLinesViewOnPaperPreview(hdlS, New Size(800, 600), 0.25)
        ViewportLayout1.StartWork(hdl)
    
        'Restore saved view
        ViewportLayout1.RestoreView(cameraSaved)
    End Sub

    Through HiddenLinesViewSetting class you can customize several preview parameters (here you can see PenEdge and PenSilhouette color set to Blue, and their width line thickness set to one).

    Finally, object HiddenLinesViewOnPaperPreview creates the preview opening the window reported below.

    print_preview.png

    Please note that HiddenLinesViewOnPaperPreview class takes as arguments the settings we have created first, the dimensions of the preview windows and the scale factor. Scale factor permits you to calibrate the dimension of your entities on paper. If you want, for example, print the entities with the same dimension you have drawn them on viewport, you should set scale factor to 1.

    Finally, if you prefer to print directly without displaying the preview window, you should use HiddenLinesViewOnPaper object instead of HiddenLinesViewOnPaperPreview.